/**
 * Copyright (C), 2015-2021, XXX有限公司
 * FileName: FilesVisitService
 * Author:   wh
 * Date:     2021/12/2 23:04
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package org.jeecg.modules.dzda.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.dzda.entity.FileVisit;
import org.jeecg.modules.dzda.mapper.FilesVisitMapper;
import org.jeecg.modules.dzda.service.FilesVisitService;
import org.springframework.stereotype.Service;

/**
 * 功能描述:
 * <>
 *
 * @program: wh-boot
 * @ClassName: FilesVisitService
 * @author: wanghui
 * @date: 2021/12/2 23:04
 * @Version: 1.0.0
 *
 * @Copyright: 2021 Inc. All rights reserved. 注意: 本内容仅限于内部传阅,禁止外泄以及用于其他的商业目
 */
@Service
public class FilesVisitServiceImpl extends ServiceImpl<FilesVisitMapper, FileVisit> implements FilesVisitService {

    @Override
    public void addVisit(FileVisit fileVisit){
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        fileVisit.setSys_user_code(sysUser.getUsername());
        fileVisit.setSys_org_code(sysUser.getOrgCode());
        baseMapper.addVisit(fileVisit);
    }

    /**
     * 作用: 获取借阅记录
     * 场景:
     * 其他:
     *
     * @param fileVisit
     * @return org.jeecg.modules.dzda.entity.FileVisit
     * @throws
     * @Title getVisit
     * @Author: wanghui
     * @Date 2021/12/3 15:39
     */
    @Override
    public FileVisit getVisit(FileVisit fileVisit) {
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        fileVisit.setSys_user_code(sysUser.getUsername());
        fileVisit.setSys_org_code(sysUser.getOrgCode());
        return baseMapper.getVisit(fileVisit);
    }

    /**
     * 作用: 更新借阅记录状态
     * 场景:
     * 其他:
     *
     * @return void
     * @throws
     * @Title updateVisit
     * @Author: wanghui
     * @Date 2021/12/3 16:38
     */
    @Override
    public void updateVisitStatus() {
        baseMapper.updateVisitStatus();
    }
}
